package com.yanghang.zuulclient.controller;

import org.apache.commons.lang.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Objects;
import java.util.regex.Pattern;

/**
 * @program: springcloudcode
 * @description: 正则匹配客户端
 * @author: YangHang
 * @create: 2019-08-27 23:11
 **/

@RestController
@RequestMapping("regex")
public class RegexController {

    @GetMapping("/isMatcher")
    public boolean isMatcher(String str) {
        if (Objects.nonNull(str)){
            System.out.println(str);
            return true;
        }

        if (StringUtils.isEmpty(str)) {
            return false;
        }
        String regex = "^re\\w?$";
        return Pattern.matches(regex, str);
    }
}
